/**
 * Copyright (c) 2005-2016, yinwer81 (yinwer81@aliyun.com)
 *
 * Licensed under the Apache License, Version 2.0
 */
package com.nozturn.throne.service;

import com.nozturn.throne.entity.Authorization;
import com.nozturn.throne.entity.OAuthInfoDTO;

public interface OAuthService {

    // 添加 authorization code
    int addAuthorizationCode(final String authorizationCode, final Long clientPk, final Long userPk);

    // 验证authorization code是否有效
    boolean checkAuthorizationCode(final String authorizationCode);

    // 添加 access token
    int addAccessToken(final String accessToken, final Long authorizationPk);

    // 验证access token是否有效
    boolean checkAccessToken(final String accessToken);

    String getUsernameByAuthorizationCode(final String authorizationCode);

    String getUsernameByAccessToken(final String accessToken);
    
    Authorization findByUserPkAndClientPk(final Long userPk, final Long clientPk);

    // authorization code / access token 过期时间
    int getExpireIn();

    boolean checkClientId(final String clientId);

    boolean checkClientSecret(final String clientSecret);

    public OAuthInfoDTO findAllByAuthorizationCode(final String authorizationCode);

    public OAuthInfoDTO findAllByAccessToken(final String accessToken);

}
